import org.ki4.kipastelsys.*
import org.ki4.kipastelsys.auth.*
import org.ki4.kipastelsys.enums.*

class BootStrap {
	
	def springSecurityService
	
	def init = { servletContext ->
		if (!Pessoa.count()) {
			createData()
		}
	}
    
	def destroy = {
	}
    

	private void createData() {
		def admin = new Funcao(authority: 'ROLE_ADMIN').save()

		String password = springSecurityService.encodePassword('123')
		Date data = new Date();

		def pAdmin = new Admin(nome:'Flavio', endereco:'Av. republica francesa', telefone:'33222197', cpf:'06426466433', sexo: Sexo.Masculino, username:'fsr', password:password, enabled: true, dataDeNascimento: data).save()
		PessoaFuncao.create pAdmin, admin, true
	}
}
